#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define ll long long
#define MN 100005
using namespace std;
ll n,ans,cnt,r[MN],qz[MN],xt[MN];
vector<ll>xls;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>r[i];
        xt[r[i]]++;
    }
    for(ll i=1;i<=MN;i++){
        qz[i]=xt[i]+qz[i-1];
        if(xt[i]!=0)
            xls.push_back(i);
    }
    for(ll i=0;i<xls.size()-1;i++){
        if(qz[xls[xls.size()-1]]-qz[xls[i]]-cnt>=xt[xls[i]]){
            ans+=xt[xls[i]];
            if(i+1<xls.size())
                cnt=max((ll)(0),xt[xls[i]]+cnt-xt[xls[i+1]]);
        }
        else{
            ans+=(qz[xls[xls.size()-1]]-qz[xls[i]]-cnt);
            break;
        }
    }
    cout<<n-ans;
    return 0;
}
